import React from 'react';


import classnames from 'classnames';
//component
import ReIcon from 'components/widgets/ReIcon';


import './index.less';


export default class view extends React.Component {
    static propTypes = {
        //name: React.PropTypes.string,
    };

    static defaultProps = {
        //name: 'component name'
    };


    constructor(props, context) {

        super(props, context);


        // init state;
        this.state = {};
    }

    componentWillMount() {
        this._isMounted = true;

    }

    componentDidMount() {

    }

    componentWillUnmount() {
        this._isMounted = false;
    }

    renderIntroduce(str) {
        if (!str) {
            return;
        }
        let arr = str.split('\n');
        let dom = arr.map((item, index) => {
            return [
                <span key={index}>{item}</span>,
                <br/>
            ]
        });
        return dom;
    }

    renderPlat() {
        let exhibitioninfo = this.props.detailInfo;
        let tagDom = exhibitioninfo.tags && $$.utils.tagsChangeArray(exhibitioninfo.tags).map(function(item, index) {
            return <span key={index}>{item.value}</span>;
        });
        return (
            <div className="exhibitioninfo-plat">
                <div className="title">{exhibitioninfo.name}</div>
                <div className="describe">{this.renderIntroduce(exhibitioninfo.introduce)}</div>
                {
                    exhibitioninfo.releaseTime &&
                    <div className="label">
                        <ReIcon icon="time"/>
                        {$$.utils.releaseTime(exhibitioninfo.releaseTime)}{$$.LN.PUBLISH}
                    </div>
                }
                <div className="label">
                    <ReIcon icon="display"/>
                    {exhibitioninfo.viewNumber ? exhibitioninfo.viewNumber : 0}{$$.LN.COUNT_VIEW}
                </div>
                <div className="label">
                    <ReIcon icon="zan"/>
                    {exhibitioninfo.giveLike ? exhibitioninfo.giveLike : 0}{$$.LN.COUNT_AGREE}
                </div>
                {
                    tagDom &&
                    <div className="label">
                        <ReIcon icon="label"></ReIcon>
                        {tagDom}
                    </div>
                }
            </div>
        );
    }

    render() {

        const classNames = classnames({
            'orin-w-exhibitioninfoplat-root': true,
            [this.props.className]: this.props.className ? true : false
        });

        return (
            <div className={classNames}>
                {this.renderPlat()}
            </div>
        );
    }
}
